package com.smag.web.controller.echarts.line;

import com.smag.common.annotation.Log;
import com.smag.common.core.controller.BaseController;
import com.smag.common.core.domain.AjaxResult;
import com.smag.common.core.page.TableDataInfo;
import com.smag.common.enums.BusinessType;
import com.smag.common.utils.poi.ExcelUtil;
import com.smag.echarts.domain.EchartsLineEconomy;
import com.smag.echarts.service.EchartsLineEconomyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController("lineEconomyController")
@RequestMapping("/echarts/line/economy")
public class EconomyController extends BaseController {
    @Resource
    private EchartsLineEconomyService echartsLineEconomyService;
    @GetMapping("/listAll")
    public AjaxResult getEconomyList(){
        return echartsLineEconomyService.getEconomyList();
    }

    /**
     * 查询政府农业投入与农村消费水平列表
     */
    @PreAuthorize("@ss.hasPermi('system:economy:list')")
    @GetMapping("/list")
    public TableDataInfo list(EchartsLineEconomy echartsLineEconomy)
    {
        startPage();
        List<EchartsLineEconomy> list = echartsLineEconomyService.selectEchartsLineEconomyList(echartsLineEconomy);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:economy:export')")
    @Log(title = "政府农业投入与农村消费水平", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EchartsLineEconomy echartsLineEconomy)
    {
        List<EchartsLineEconomy> list = echartsLineEconomyService.selectEchartsLineEconomyList(echartsLineEconomy);
        ExcelUtil<EchartsLineEconomy> util = new ExcelUtil<EchartsLineEconomy>(EchartsLineEconomy.class);
        util.exportExcel(response, list, "政府农业投入与农村消费水平数据");
    }

    /**
     * 获取政府农业投入与农村消费水平详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:economy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return echartsLineEconomyService.selectEchartsLineEconomyById(id);
    }

    /**
     * 新增政府农业投入与农村消费水平
     */
    @PreAuthorize("@ss.hasPermi('system:economy:add')")
    @Log(title = "政府农业投入与农村消费水平", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EchartsLineEconomy echartsLineEconomy)
    {
        return echartsLineEconomyService.insertEchartsLineEconomy(echartsLineEconomy);
    }

    /**
     * 修改政府农业投入与农村消费水平
     */
    @PreAuthorize("@ss.hasPermi('system:economy:edit')")
    @Log(title = "政府农业投入与农村消费水平", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EchartsLineEconomy echartsLineEconomy)
    {
        return echartsLineEconomyService.updateEchartsLineEconomy(echartsLineEconomy);
    }

    /**
     * 删除政府农业投入与农村消费水平
     */
    @PreAuthorize("@ss.hasPermi('system:economy:remove')")
    @Log(title = "政府农业投入与农村消费水平", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return echartsLineEconomyService.deleteEchartsLineEconomyByIds(ids);
    }
}
